package cn.znzz.cjm.feign;

import cn.znzz.cjm.doc.CourseDoc;
import cn.znzz.cjm.doc.QueryDoc;
import cn.znzz.cjm.query.CourseQuery;
import cn.znzz.cjm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseDocFallBackFactory implements FallbackFactory<CourseDocFeignClient>{
    @Override
    public CourseDocFeignClient create(Throwable throwable) {
        return new CourseDocFeignClient() {
            @Override
            public AjaxResult saveCourseDoc(CourseDoc doc) {
                return AjaxResult.me().setSuccess(false).setMessage("课程上线失败,搜索服务异常");
            }

            @Override
            public AjaxResult delCourseDoc(CourseDoc doc) {
                return AjaxResult.me().setSuccess(false).setMessage("课程下线失败,搜索服务异常");
            }

            @Override
            public AjaxResult queryCourses(QueryDoc queryDoc) {
                return AjaxResult.me().setSuccess(false).setMessage("搜索服务异常");
            }
        };
    }
}
